package com.hzhr.iot.toll.convertor;

import com.hzhr.iot.toll.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserPostModel;
import com.hzhr.iot.toll.entity.UserGasUserEntity;
import com.hzhr.iot.toll.entity.ext.UserGasUserEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserGetModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserPostModel;
import com.hzhr.iot.toll.queryModel.custom.UserGasUserCustomQueryModel;

@Component
public class UserGasUserConvertor {
    @Autowired
    GasUserCustomConvertor gasUserCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;

    public UserGasUserEntity userGasUserModel2entity(UserGasUserModel in) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserEntity result = new UserGasUserEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public UserGasUserEntity userGasUserModel2entity(UserGasUserModel in, UserGasUserEntity ori) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserEntity> userGasUserModelList2entityList(List<UserGasUserModel> in) {
        if (in == null) return null;
        List<UserGasUserEntity> result = new ArrayList<>();
        for (UserGasUserModel item : in) {
            result.add(userGasUserModel2entity(item));
        }
        return result;
    }
    public UserGasUserModel entity2userGasUserModel(UserGasUserEntity in) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserModel result = new UserGasUserModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserModel> entityList2userGasUserModelList(List<UserGasUserEntity> in) {
        if (in == null) return null;
        List<UserGasUserModel> result = new ArrayList<>();
        for (UserGasUserEntity item : in) {
            result.add(entity2userGasUserModel(item));
        }
        return result;
    }
    public UserGasUserModel ext2userGasUserModel(UserGasUserEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserModel result = new UserGasUserModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserModel> extList2userGasUserModelList(List<UserGasUserEntityExt> in) {
        if (in == null) return null;
        List<UserGasUserModel> result = new ArrayList<>();
        for (UserGasUserEntityExt item : in) {
            result.add(ext2userGasUserModel(item));
        }
        return result;
    }
    public UserGasUserGetModel extList2userGasUserGetModel(List<UserGasUserEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<UserGasUserModel> modelList = extList2userGasUserModelList(extList);
        if (modelList == null) {
            UserGasUserGetModel result = new UserGasUserGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));


        UserGasUserGetModel result = new UserGasUserGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public UserGasUserGetModel entity2userGasUserGetModel(UserGasUserEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<UserGasUserEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2userGasUserGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, UserGasUserEntityExt.class));
        return extList2userGasUserGetModel(extList, total, changeCount, query);
     }
    public UserGasUserEntity userGasUserPostModel2entity(UserGasUserPostModel in) {
        //未转换字段: id 
        if (in == null) return null;
        UserGasUserEntity result = new UserGasUserEntity();

        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public UserGasUserEntity userGasUserPostModel2entity(UserGasUserPostModel in, UserGasUserEntity ori) {
        //未转换字段: id 
        if (in == null) return null;
        UserGasUserEntity result = ori;

        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserEntity> userGasUserPostModelList2entityList(List<UserGasUserPostModel> in) {
        if (in == null) return null;
        List<UserGasUserEntity> result = new ArrayList<>();
        for (UserGasUserPostModel item : in) {
            result.add(userGasUserPostModel2entity(item));
        }
        return result;
    }
    public UserGasUserPostModel entity2userGasUserPostModel(UserGasUserEntity in) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserPostModel result = new UserGasUserPostModel();

        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserPostModel> entityList2userGasUserPostModelList(List<UserGasUserEntity> in) {
        if (in == null) return null;
        List<UserGasUserPostModel> result = new ArrayList<>();
        for (UserGasUserEntity item : in) {
            result.add(entity2userGasUserPostModel(item));
        }
        return result;
    }
    public UserGasUserPostModel ext2userGasUserPostModel(UserGasUserEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        UserGasUserPostModel result = new UserGasUserPostModel();

        result.setUserId(HzhrTypeUtil.integer2integer(in.getUserId()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        return result;
    }
    public List<UserGasUserPostModel> extList2userGasUserPostModelList(List<UserGasUserEntityExt> in) {
        if (in == null) return null;
        List<UserGasUserPostModel> result = new ArrayList<>();
        for (UserGasUserEntityExt item : in) {
            result.add(ext2userGasUserPostModel(item));
        }
        return result;
    }
    public UserGasUserCustomQueryModel userGasUserService_query2queryModel(Map<String, Object> query) {
        UserGasUserCustomQueryModel queryModel = new UserGasUserCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_userId = HzhrTypeUtil.object2integer(query.get("_equal_userId"));
        if (_equal_userId != null) {
            queryModel.setEqual_userId(_equal_userId);
         }

        Integer _equal_gasUserId = HzhrTypeUtil.object2integer(query.get("_equal_gasUserId"));
        if (_equal_gasUserId != null) {
            queryModel.setEqual_gasUserId(_equal_gasUserId);
         }

        queryModel.setShow(true);
        queryModel.setShow(true);

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

